/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.IDemandeDao;
import com.nxlv2.nomad.accessdb.dao.IDetailDemandeDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcDemandeDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcDetailDemandeDao;
import com.nxlv2.nomad.businessobjects.Article;
import com.nxlv2.nomad.businessobjects.Demande;
import com.nxlv2.nomad.businessobjects.DetailDemande;
import com.nxlv2.nomad.businessobjects.Prix;
import java.util.List;

/**
 *
 * @author Administrateur
 */
public class DetailDemandeServices {
    private static final IDetailDemandeDao dao = new JdbcDetailDemandeDao();
    private static final IDemandeDao daoD = new JdbcDemandeDao();
    
    /**
     * 
     * @param detailDemande
     * @param demande
     * @throws ServiceException 
     */
    public void create(DetailDemande detailDemande, Demande demande) throws ServiceException {
        dao.saveDetailDemande(detailDemande);
        daoD.lierDetailDemandeADemande(detailDemande, demande);
    }
    
    /**
     * 
     * @param detailDemande
     * @throws ServiceException 
     */
    public void update(DetailDemande detailDemande) throws ServiceException  {
        dao.updateDetailDemande(detailDemande);
    }

    /**
     * 
     * @param detailDemande
     * @throws ServiceException 
     */
    public void delete(DetailDemande detailDemande) throws ServiceException {
        dao.deleteDetailDemande(detailDemande.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return List<DetailDemande>
     * @throws ServiceException 
     */
    public List<DetailDemande> get(int id) throws ServiceException {
        return dao.findDetailDemandeById(id);
    }
    
    /**
     * 
     * @param detailDemande
     * @return Article
     * @throws ServiceException 
     */
    public Article getArticle(DetailDemande detailDemande) throws ServiceException {
        return dao.getArticle(detailDemande);
    }

    /**
     * 
     * @param article
     * @param detailDemande
     * @throws ServiceException 
     */
    public void linkArticle(Article article, DetailDemande detailDemande) throws ServiceException {
        dao.lierArticleADetailDemande(article, detailDemande);
    }
    
    /**
     * 
     * @param detailDemande
     * @return Prix
     * @throws ServiceException 
     */
    public Prix getPrix(DetailDemande detailDemande) throws ServiceException {
        return dao.getPrix(detailDemande);
    }
    
    /**
     * 
     * @param prix
     * @param detailDemande
     * @throws ServiceException 
     */
    public void linkPrix(Prix prix, DetailDemande detailDemande) throws ServiceException {
        dao.lierPrixADetailDemande(prix, detailDemande);
    }
}
